<template>
  <div class="homeIcons">
    <swiper :options="swiperOptions">
      <swiper-slide v-for="(page, index) of pages" :key="index">
        <div class="icon" v-for="aa of page" :key="aa.id">
          <div class="iconImg">
            <img class="iconImgCon" :src="aa.imgUrl">
            <p class="msg">{{aa.title}}</p>
          </div>
        </div>
      </swiper-slide>
      <!--<div class="swiper-pagination" slot="pagination"></div>-->
    </swiper>
  </div>
</template>

<script>
export default {
  name: 'HomeIcons',
  props: {
    iconList: Array,
  },
  data() {
    return {
      swiperOptions: {
        display:false
      }
    };
  },
  computed: {
    pages() {
      const pages = [];
      this.iconList.forEach((item, index) => {
        const page = Math.floor(index / 8);
        if (!pages[page]) {
          pages[page] = [];
        }
        pages[page].push(item);
      });
      return pages;
    },
  },
};
</script>

<style scoped>
  /*@import '../../../style/mixins.styl'*/

.homeIcons >>> .swiper-container{
  height: 0;
  padding-bottom: 50%;
}
.homeIcons {
  margin-top: 5px;
  overflow: hidden;
  height: 0;
  padding-bottom: 50%;
}
.icon{
  height: 0;
  position: relative;
  overflow: hidden;
  float:left;
  width: 25%;
  padding-bottom: 25%;
}
.iconImg{
  position: absolute;
  top: 0px;
  left: 0px;
  right: 0px;
  bottom: 25px;
  box-sizing: border-box;
  padding: 5px;
}
.iconImgCon{
  display: block;
  margin: 0 auto;
  height: 100%;
}
.msg{
  position: absolute;
  left: 0px;
  right: 0px;
  bottom: 0px;
  height: 10px;
  line-height: 8px;
  color: #333;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;

}
</style>
